package com.qmx.qmxapp.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.qmx.qmxapp.R;
import com.qmx.qmxapp.base.BaseActivity;
import com.qmx.qmxapp.callback.DialogCallback;
import com.qmx.qmxapp.constant.AppConstant;
import com.qmx.qmxapp.constant.ComParamContact;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ForgotPasswordCodeActivity extends BaseActivity {

    private TextView tip_content;
    @BindView(R.id.next)
    TextView next;
    @BindView(R.id.send_code)
    TextView send_code;
    @BindView(R.id.edit_phone)
    TextView edit_phone;
    @BindView(R.id.edit_password)
    EditText edit_password;

    private String mobile = "";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_forgot_password_code);
        ButterKnife.bind(this);
        tip_content = findViewById(R.id.tip_content);
        tip_content.setText("找回密码");

        mobile = this.getIntent().getStringExtra("mobile");

    }

    @OnClick(R.id.next)
    public void onclick(View view) {
        getCode();
    }

    private void getCode() {
        OkGo.<String>post(AppConstant.Url + ComParamContact.sendValidCode.PATH)
                .params(ComParamContact.sendValidCode.AREA_CODE, "+86")
                .params(ComParamContact.sendValidCode.MOBILE, mobile)
                .params(ComParamContact.sendValidCode.EVENT, "resetpwd")
                .execute(new DialogCallback<String>(this) {

                    @Override
                    public void onSuccess(Response<String> response) {
                        showToast(response.body());
//                            handleResponse(response);
                    }

                    @Override
                    public void onError(Response<String> response) {
                        showToast("接口有问题");
//                            handleError(response);
                    }
                });
    }

    private void setNewPassword() {
        OkGo.<String>post(AppConstant.Url + ComParamContact.Resetpwd.PATH)
                .headers(ComParamContact.Resetpwd.TOKEN, "82f79b7f-9e66-4ebc-af7a-d0e918731b97")
                .params(ComParamContact.Resetpwd.AREA_CODE, "+86")
                .params(ComParamContact.Resetpwd.MOBILE, mobile)
                .params(ComParamContact.Resetpwd.CAPTCHA, "")
                .params(ComParamContact.Resetpwd.PASSWORD, "")
                .execute(new DialogCallback<String>(this) {

                    @Override
                    public void onSuccess(Response<String> response) {
                        showToast(response.body());
//                            handleResponse(response);
                    }

                    @Override
                    public void onError(Response<String> response) {
                        showToast("接口有问题");
//                            handleError(response);
                    }
                });
    }

}
